//
//  TransferDetailsViewController.m
//  HYApp
//
//  Created by Jianbo Cai on 2020/9/4.
//  Copyright © 2020 Unidax. All rights reserved.
//

#import "TransferDetailsViewController.h"
#import "HYNetHelper.h"

@interface TransferDetailsViewController ()

//@property (nonatomic, strong) TransfersListEntity *transfersEntity;

@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property (weak, nonatomic) IBOutlet UILabel *typeLabel;
@property (weak, nonatomic) IBOutlet UILabel *amountLabel;
@property (weak, nonatomic) IBOutlet UILabel *fromWalletLabel;
@property (weak, nonatomic) IBOutlet UILabel *toWalletLabel;
@property (weak, nonatomic) IBOutlet UILabel *statusLabel;
@property (weak, nonatomic) IBOutlet UILabel *hashLabel;
@property (weak, nonatomic) IBOutlet UILabel *refLabel;
@property (weak, nonatomic) IBOutlet UILabel *feeLabel;
@property (weak, nonatomic) IBOutlet UILabel *speedLabel;
@property (weak, nonatomic) IBOutlet UILabel *settlementLabel;

@property (weak, nonatomic) IBOutlet UILabel *dateTitle;
@property (weak, nonatomic) IBOutlet UILabel *typeTitle;
@property (weak, nonatomic) IBOutlet UILabel *amountTitle;
@property (weak, nonatomic) IBOutlet UILabel *fromWalletTitle;
@property (weak, nonatomic) IBOutlet UILabel *toWalletTitle;
@property (weak, nonatomic) IBOutlet UILabel *statusTitle;
@property (weak, nonatomic) IBOutlet UILabel *hashTitle;
@property (weak, nonatomic) IBOutlet UILabel *refTitle;
@property (weak, nonatomic) IBOutlet UILabel *feeTitle;
@property (weak, nonatomic) IBOutlet UILabel *speedTitle;
@property (weak, nonatomic) IBOutlet UILabel *settlementTitle;

@property (weak, nonatomic) IBOutlet UIButton *downButton;

@end

@implementation TransferDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"Details";

    self.dateTitle.text = JFMainLocalizedString(@"transactions.date");
    self.typeTitle.text = JFMainLocalizedString(@"transactions.type");
    self.amountTitle.text = JFMainLocalizedString(@"transactions.asset");
    self.fromWalletTitle.text = JFMainLocalizedString(@"transactions.from_wallet");
    self.toWalletTitle.text = JFMainLocalizedString(@"transactions.to_wallet");
    self.statusTitle.text = JFMainLocalizedString(@"transactions.status");
    self.hashTitle.text = JFMainLocalizedString(@"transactions.private_transaction_hash");
    self.refTitle.text = JFMainLocalizedString(@"transactions.ref_id");
    self.feeTitle.text = JFMainLocalizedString(@"withdraw.fee");
    [self.downButton setTitle:JFMainLocalizedString(@"Download") forState:UIControlStateNormal];
    
    [self requestDetails];
    [self updateData];
}

- (void)updateData {
    self.fromWalletLabel.text = [self.transfersEntity.from_account_label getAccountString];
    self.toWalletLabel.text = [self.transfersEntity.to_account_label getAccountString];
    self.amountLabel.text = [NSString stringWithFormat:@"%@ %@", self.transfersEntity.amount, self.transfersEntity.asset_symbol];
    self.hashLabel.text = self.transfersEntity.private_txn_hash;
    self.statusLabel.text = self.transfersEntity.status;
    self.typeLabel.text = self.transfersEntity.type;
    self.dateLabel.text = self.transfersEntity.date;
    self.refLabel.text = self.transfersEntity.ref_id;
    self.feeLabel.text = self.transfersEntity.fee_amount;
    self.speedLabel.text = self.transfersEntity.tenor;
    self.settlementLabel.text = self.transfersEntity.settlement_time;
}

- (void)requestDetails {
//    WEAKSELF
//    [HYNetHelper transactions2:self.transfer_id callback:^(JFResultVo *resultVo) {
//        if (!resultVo.errorNo) {
//            weakSelf.transfersEntity = [TransfersListEntity yy_modelWithDictionary:resultVo.results];
//            [weakSelf updateData];
//        }
//    }];
}

#pragma mark - Table view data source
- (IBAction)downAction:(id)sender {
    UIImage *image = [UIImage getImageWithScrollView:self.tableView];
    UIImageWriteToSavedPhotosAlbum(image, nil, nil,nil);;
}
@end
